clear all

********************************************************************************
********************************************************************************
**** When Can We Trust Regression Discontinuity Design Estimates from Close ****
*************** Elections? Evidence from Experimental Benchmarks ***************
********************************************************************************
********************************************************************************

* This file produces Table OA13 in Online Appendix D of De Magalhaes et al. 
* (Political Analysis).

cd "$dir"
use "$dir/data/personal_incumbency_advantage.dta", clear

********************************************************************************

la var elected "Elected"
gen within_party = 100 * votes/partyvotes

********************************************************************************

est clear 

foreach x of varlist votes within_party voteshare female incumbent {
	eststo: reg `x' elected if rv == 0 & country == "Colombia", cluster(constituency)
}

esttab est* using "$dir/tables/table_OA13.tex", booktabs ///
keep(elected) ///
	mgroups("Votes" "Within-party vote share" "Within-municipality vote share" "Female" "Incumbent",  pattern(1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) nomtitles ///
replace  nonotes ///
ci(%9.3f) b(%9.3f) stats(N, fmt(0)  layout(@) ///
labels("\textit{N}" )) collabels(none) ///
label nostar	eqlabels(none) ///
prehead(\begin{tabular}{l*{6}{c}} \toprule) ///
postfoot("") refcat(Conventional "\textbf{Panel A:} Colombia", nolabel)

est clear

foreach x of varlist votes within_party voteshare female incumbent {
	eststo: reg `x' elected if rv == 0 & country == "Finland", cluster(constituency)
}

esttab est* using "$dir/tables/table_OA13.tex", booktabs ///
keep(elected) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N, fmt(0)  layout(@) ///
labels("\textit{N}" )) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot(\bottomrule \end{tabular})	refcat(Conventional "\textbf{Panel B:} Finland", nolabel)

est clear
